<?xml version="1.0" encoding="UTF-8"?>
<!--
	
                 Springs On Rails
                 Copyright [2007] [Sunny Liu]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.	
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<!--
				<value>WEB-INF/mail.properties</value>
				-->
				<value>WEB-INF/jdbc.properties</value>
			</list>
		</property>
</bean>

 <!-- After you setup database and connection properties -->
 <!-- You can uncomment out one of following datasource to suit your need -->
 <!--
 <#noparse>		
	<jee:jndi-lookup id="dataSource" jndi-name="${jdbc.jndiName}"/>		
 </#noparse>  
 -->
 <!--
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
	<#noparse>
	  <property name="driverClassName" value="${jdbc.driverClassName}" />
	  <property name="url" value="${jdbc.url}" />
	  <property name="username" value="${jdbc.username}" />
	  <property name="password" value="${jdbc.password}" />
	</#noparse>
  </bean>
 -->
 
 <!-- ORM section -->
 <!-- You can uncomment out this section for ORM support that suits your need -->
 <!--
  <#if appConfig.ormType=="hibernate" >  
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
      <list>
       <#list entities as entity> 
        <value>/${appConfig.outputPackageNameInFilePath}/model/mapping/${entity.javaName}.hbm.xml</value>
       </#list>
      </list>
    </property>
    <property name="hibernateProperties">
      <value>
        <#if appConfig.dbType=="oracle">
        	hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
        <#elseif appConfig.dbType=="mysql">
        	hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
        <#elseif appConfig.dbType=="mssql">
        	hibernate.dialect=org.hibernate.dialect.SQLServerDialect
        <#elseif appConfig.dbType=="sybase">
        	hibernate.dialect=org.hibernate.dialect.SybaseDialect
        <#elseif appConfig.dbType=="db2">
        	hibernate.dialect=org.hibernate.dialect.DB2Dialect
        <#else>
        	hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
        </#if>
      </value>
    </property>
  </bean>
  <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.hibernate.${entity.javaName}DAOImpl">
      <property name="sessionFactory" ref="sessionFactory"/>
  </bean>     
   </#list>   
  <#else>
   <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation" value="WEB-INF/sql-map-config.xml"/>
		<property name="dataSource" ref="dataSource"/>
  </bean>
  <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.ibatis.${entity.javaName}DAOImpl">
     <property name="sqlMapClient" ref="sqlMapClient"/>
  </bean>     
   </#list>
   </#if>  
   -->
   
  
  <!-- Uncomment following section for declaretive transaction management support. -->
  <!--
   <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
		<property name="autodetectTransactionManager" value="false" />
	</bean>	  
   <tx:advice id="txAdvice" transaction-manager="transactionManager">    
    <tx:attributes>      
      <tx:method name="get*" read-only="true"/>
      <tx:method name="find*" read-only="true"/>      
      <tx:method name="*"/>
    </tx:attributes>
  </tx:advice>  
  <aop:config>
    <aop:pointcut id="transproxyOperation" expression="execution(* ${appConfig.outputPackageName}.trans.TransactionProxy.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="transproxyOperation"/>
  </aop:config>
  -->
  
  <!-- This is mock testing section, uncomment this section once you enabled ORM section -->
  <#list entities as entity>    
  <bean id="${entity.normalizedJavaName}DAO" class="${appConfig.outputPackageName}.dao.mock.${entity.javaName}DAOImpl">
  </bean>     
  </#list>
  
  
   <!-- this is the service object that we want to make transactional --> 
   <bean id="transactionProxy" class="${appConfig.outputPackageName}.trans.TransactionProxyImpl">
     <#list  entities as entity>	
		<property name="${entity.normalizedJavaName}DAO" ref="${entity.normalizedJavaName}DAO"/>		
	</#list>
  </bean>     

</beans>
